//
//  DWThemeTabContainer.swift
//  DWSwift
//
//  Created by GDL on 2025/6/20.
//

import Foundation
import SwiftUI

struct DWThemeTabContainer<Content: View>: View {
    @ViewBuilder let content: (DWThemeTab) -> Content
    @State private var currentTab: DWThemeTab = .home
    @Environment(\.colorScheme) private var colorScheme
    
    var body: some View {
        ZStack(alignment: .bottom) {
            // 主内容区
            content(currentTab)
                .frame(maxWidth: .infinity, maxHeight: .infinity)
            // TabBar 浮动于内容上方
            DWThemeTabBar(selectedTab: $currentTab, tabs: DWThemeTab.allCases, action:{tab in
                print("当前：\(currentTab)")
                print("将要改变：\(tab)")
                currentTab=tab
            })
        }
        .background(
            colorScheme == .dark ? Color.black : Color.white // 全局背景适配
        )
    }
}


